﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sinacor.Infra.Tools.ErrorLogCollector
{
    public class ClientCollector
    {
        public LogPackage Collect(DateTime from, DateTime to)
        {
            LogPackage package = new LogPackage();
            package.Client = new Package<ClientEnvironmentData>();

            EventLogCollector eventLogCollector = new EventLogCollector();
            EnvironmentCollector environmentCollector = new EnvironmentCollector();

            package.Client.Environment = environmentCollector.CollectClientEnvironment();
            
            // UI
            package.Client.Logs.AddRange(eventLogCollector.Collect("Sinacor", LogSource.UserInterface, from, to).Cast<LogData>());

            // Ordena por data
            package.Client.Logs = package.Client.Logs.OrderBy(l => l.Date).Reverse().ToList();

            return package;
        }
    }
}
